<template>
  <div class="login">
    <van-nav-bar title="绑定" />
    <van-image :src="imgSrc" fit="contain" class="banner" />
    <div class="login-body login">
      <van-form @submit="onSubmit">
        <van-field
          v-model="username"
          name="username"
          label="账号"
          placeholder="账号"
          :rules="[{ required: true, message: '请填写账号' }]"
        />
        <van-field
          v-model="password"
          type="password"
          name="password"
          label="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
        />
        <div style="margin: 16px">
          <van-button round block color="#1989fa" class="van-btn" native-type="submit"
            >绑定</van-button
          >
        </div>
      </van-form>
    </div>
  </div>
</template>

<script>
import imgSrc from "@/assets/Images/banner.png";
import { reactive, toRefs } from "vue";
// import sHeader from "@/components/SimpleHeader";
// import { login } from "@/service/user";
import { saveWechatUser } from "@/service/home"
// import { setLocal } from "@/common/js/utils";
// import { Toast } from "vant";
export default {
  name:'GovernmentBind',
  setup() {
    const state = reactive({
      imgSrc: imgSrc,
      username: "",
      password: "",
    });
    // 提交登录或注册表单
    const onSubmit = async (values) => {
        const { data } = await saveWechatUser({
          account: values.username,
          password: values.password,
        });
        console.log(data)
        // setLocal("token", data);
        // 需要刷新页面，否则 axios.js 文件里的 token 不会被重置
        // window.location.href = "/";
    };

    return {
      ...toRefs(state),
      onSubmit,
    };
  },
  // components: {
  //   sHeader,
  // },
};
</script>

<style lang="less" scoped>
.login {
  background: linear-gradient(90deg, #ffffff, #ffffff);
  .banner {
    margin: 50px 20px;
    border-radius: 10px;
    box-shadow: 2px 2px 10px #1989fa;
  }
  .logo {
    width: 120px;
    height: 120px;
    display: block;
    margin: 80px auto 20px;
  }
  .login-body {
    padding: 0 20px;
  }
  .login {
    .link-register {
      font-size: 18px;
      margin-bottom: 20px;
      color: #1989fa;
      display: inline-block;
    }
  }
  .van-btn {
    margin-top: 30px;
    font-size: 18px;
  }
  /deep/ .van-cell {
    font-size: 20px;
    margin-right: 1px;
    width:100%;
  }
}
</style>
